package com.cloud.bc.controller;

import com.cloud.bc.model.domain.UserInfo;
import com.cloud.bc.model.entity.BcSingles;
import com.cloud.bc.model.entity.BcUsers;
import com.cloud.bc.service.BcSinglesService;
import com.cloud.bc.service.BcUsersService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@AllArgsConstructor
@RequestMapping("m/center/setup")
public class MCenterSetupController extends BaseController {

    private final BcUsersService bcUsersService;
    private final BcSinglesService bcSinglesService;

    /**
     * 设置
     */
    @GetMapping("")
    public ModelAndView setup(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"设置", "m/center/setup/index");
        UserInfo userInfo = bcUsersService.getUserInfo(request);
        BcUsers userModel = bcUsersService.getById(userInfo.getId());
        BcSingles bcSingles = bcSinglesService.selectOne(new BcSingles().setUserId(userInfo.getId()));
        view.addObject("userModel", userModel);
        view.addObject("bcSingles", bcSingles);
        return view;
    }

    /**
     * 设置
     */
    @GetMapping("userpassword")
    public ModelAndView userPassword(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"登录密码", "m/center/setup/userpassword");
        return view;
    }

    /**
     * 绑定手机
     */
    @GetMapping("usermobile")
    public ModelAndView usermobile(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView view = baseView(request,"绑定手机", "m/center/setup/usermobile");
        return view;
    }

}
